package com.miyake.dsp.converter;

import com.miyake.dsp.ComplexArray;
import com.miyake.dsp.Processor;
import com.miyake.dsp.ScilabExecute;

public class MathScilab implements Processor {

	private ComplexArray source;
	private MathSetting setting;

	public MathScilab(MathSetting setting) {
		this.setting = setting;
	}
	
	@Override
	public void setSource(ComplexArray source) {
		this.source = source;
	}

	@Override
	public ComplexArray getSource() {
		return this.source;
	}

	@Override
	public ComplexArray getProcessed() {
		if (setting.getData() != null) {
			return ScilabExecute.execute("ret=data1" + setting.getOperator() + "data2", source, setting.getData(), "ret");
		}
		else if (setting.getValue() != null) {
			return ScilabExecute.execute("ret=data1" + setting.getOperator() + setting.getValue().toString(), 
					source, "ret");
		}
		return null;
	}
	

	@Override
	public Object getSetting() {
		return this.setting;
	}

}
